<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page session="true" %>
<%@ page import="javax.portlet.*" %>
<%@page import ="rai.dto.*" %>
<%@page import ="rai.dao.*" %>
<%@page import = "java.util.*" %>

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<portlet:defineObjects/>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Personal Information Tracking System</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<script type="text/javascript" src='<%=request.getContextPath() +"/js/calendarDateInput.js"%>'></script> 
<script type="text/javascript">
	function getForm(namespace, name) {
	    return document.forms[namespace + name];
	}
	function back_to_emp_info_form(namespace, name) {
	    var frm = getForm(namespace, name);
	    frm.txtAction.value = "back_to_empInfo_form_2";
	    frm.submit();
	}
	function back_to_login(namespace, name) {
		var frm = getForm(namespace, name);
		frm.txtAction.value = "back_to_login_form";
		frm.submit();
	}
	function update_exp_action(namespace,name){
		var frm = getForm(namespace, name);
		frm.txtAction.value = "update_exp_info";
		frm.submit();
	}
</script>
<link href='<%=request.getContextPath()+"css/style.css"%>' rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
<form name="<portlet:namespace/>editExpForm" action="<portlet:actionURL/>" method="POST">
	<input type="hidden" name="txtAction" />
	<%ExperienceDTO exp= (ExperienceDTO) session.getAttribute("TakenExpInfo"); %>
	<%String succMess = (String)session.getAttribute("succMess");%>
<table align="center">
	<tr class="title">
			<td>		
					<h1><font color="blue">Personal information tracking system </font></h1>
					<p>Exploit the value of data</p>
					<hr />
			</td>
	</tr>	
	<tr>
		<td colspan="2" align="left"> Welcome, <font color="orange"/><b>[${sessionScope.role}]${sessionScope.name}</b></font>
		| <a href="#" onclick="back_to_emp_info_form('<portlet:namespace/>','editExpForm')">Home</a>
		| <a href="#" onclick="back_to_login('<portlet:namespace/>','editExpForm')">Logout</a>
	   </td>
	</tr>
	
	<tr>	
		<td>
			<table border="1">
				<tr>
					<td><h2 class="title"><font color="orange">Experience Information</font></h2></td>
				</tr>
					
				<tr>
					<td><p><em>General Information </em></p></td>
				</tr>
				<tr>
					<td>
						<table border="1" width="100%">							
							<tr>
							  <td align="left" valign="bottom">&nbsp;Company</td>
							  <td align="left" valign="middle" colspan="2"><%=exp.getCompName() %> </td>
							</tr><tr>
							  <td align="left" valign="bottom">&nbsp;Address&nbsp;</td>
							  <td align="left" valign="middle" colspan="2"><%=exp.getCompAddress() %></td>
							</tr>
							<tr>
							  <td align="left" valign="bottom">&nbsp;Phone&nbsp;</td>
							  <td align="left" valign="bottom" colspan="2"><%=exp.getCompPhone() %></td>
							</tr> 							
							  
						  
						  	<tr>
								<td>&nbsp;Department&nbsp;</td>
								<td colspan="2" align="left" valign="middle">
								  <select name="lstDept">
								  <%EditExperienceDAO dao = new EditExperienceDAO();
								    List<DepartmentDTO> list_depart = dao.getDepartment(exp.getDepartID());
								    for(int i=0;i<list_depart.size();i++){
								    DepartmentDTO depart=list_depart.get(i);
								    if(depart.getId()==exp.getDepartID()){%>
								    	<option selected value='<%=depart.getId() %>'><%=depart.getSname() %></option>
								    <%}else{ %>
								    	<option value='<%=depart.getId() %>'><%=depart.getSname() %></option>
								    <%}} %>
								  </select>
							 	</td>  
						  </tr>
							
							<tr>
							  <td align="left" valign="middle" rowspan="2">&nbsp;Working Period <%=list_depart.size() %>&nbsp;</td>
							  <td align="left" valign="bottom">From</td>
							  <td align="left" valign="middle">&nbsp;
							  <%String path = request.getContextPath(); %>
										<script>DateInput('periodFrom', true, 'DD/MM/YYYY','<%=path%>','<%=exp.getStartDate()%>');</script></td>  							 
						  </tr>
						  <tr>
							  	<td align="left" valign="bottom">&nbsp;To&nbsp;</td>
						  		<td align="left" valign="bottom">&nbsp;
										<script>
											DateInput('periodTo', true, 'DD/MM/YYYY','<%=path%>','<%=exp.getEndDate()%>');
										</script>							  </td>
						  </tr>
						  <tr>
							  	<td align="left" valign="bottom">&nbsp;Role&nbsp;</td>
								<td><textarea name="projectRole" rows="1" cols="5"></textarea></td>
						  		<td align="left" valign="middle"><select name="lstRole">
						  		 									<%EditTakenProjectDAO dao1 = new EditTakenProjectDAO();
						  		 									  List<RoleDTO> lst_role = dao1.getRole();
						  		 									  for(int i=0;i<lst_role.size();i++){
						  		 									  RoleDTO role = lst_role.get(i);
						  		 									  if(role.getSname().equals(exp.getRole())){%>
						  		 									  	<option selected value='<%=role.getId() %>'><%=role.getSname() %></option>
						  		 									  <%}else{ %>
						  		 									  	<option value='<%=role.getId() %>'><%=role.getSname() %></option>
						  		 									  <%}} %>
                                                                </select>
								</td>
								
						  </tr>
						  <tr>
						  	<td>More Description</td>
							<td colspan="2"><textarea name="txtDes" cols="" rows="2"><%=exp.getDescription() %></textarea></td>
						  </tr>

						  <tr align="left" valign="bottom">
						  	  <td colspan="3"><input type="button" name="Button2" value="Update" onclick="update_exp_action('<portlet:namespace/>','editExpForm')"/><input type="button" name="Button2" value="Cancel" onclick="back_to_emp_info_form('<portlet:namespace/>','editExpForm')"/><%=succMess %></td>
						  </tr>
				    </table>					</td>
				</tr>
			</table>			
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<div style="clear: both;">&nbsp;</div>
			<div id="footer"><p>Development by HCMUT-Grp3.</p>
			</div>
		</td>
	</tr>
</table>
</form>
</body>